/**
 * 
 */
package app.tuwien.isi.tweetanalyser;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Philipp Pospisil
 *
 */
public class Statistic {
	
	private String category;
	private List<Items> list;
	
	public Statistic() {
		this.setCategory(null);
		list = new ArrayList<Items>();
	}
	
	public Statistic(String category) {
		this.setCategory(category);
		list = new ArrayList<Items>();
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}
	
	public void addItemToList(String item) {
		boolean flag = false;
		
		for(int i=0;i<list.size();i++){
			if(item.equals(list.get(i).getItem())){
				list.get(i).setSum(list.get(i).getSum() + 1);
				flag = true;
				i = list.size();
			}
		}
		
		if(flag == false){
			list.add(new Items(item,1));
		}
	}
	
	public void addPlaceItemToList(String item, String typ, String country, String coordinates) {
		boolean flag = false;
		
		for(int i=0;i<list.size();i++){
			if(item.equals(list.get(i).getItem())){
				list.get(i).setSum(list.get(i).getSum() + 1);
				flag = true;
				i = list.size();
			}
		}
		
		if(flag == false){
			list.add(new Items(item,1,typ,country,coordinates));
		}
	}
	
	public void addUserItemToList(String item, String Location, String Language, int Followers) {
		boolean flag = false;
		
		for(int i=0;i<list.size();i++){
			if(item.equals(list.get(i).getItem())){
				list.get(i).setSum(list.get(i).getSum() + 1);
				flag = true;
				i = list.size();
			}
		}
		
		if(flag == false){
			list.add(new Items(item,1,Location,Language,Followers));
		}
	}
	
	public int getLengthOfList(){
		return list.size();
	}
	
	public String getItemOfList(int position){
		return list.get(position).getItem();
	}
	
	public int getSumOfItem(int position){
		return list.get(position).getSum();
	}
	
	public String getTypOfItem(int position) {
		return list.get(position).getTyp();
	}
	
	public String getCountryOfItem(int position) {
		return list.get(position).getCountry();
	}

	public String getCoordinatesOfItem(int position) {
		return list.get(position).getCoordinates();
	}
	
	public String getLocationOfItem(int position) {
		return list.get(position).getLocation();
	}
	
	public String getLanguageOfItem(int position) {
		return list.get(position).getLanguage();
	}

	public int getFollowersOfItem(int position) {
		return list.get(position).getFollowers();
	}
	
	class Items{
		private String item;
		private int sum;
		
		//Property for Place Items
		private String typ;
		private String country;
		private String coordinates;
		
		//Property for User Items
		private String Location;
		private String Language;
		private int Followers;
		
		
		public Items(String item, int sum){
			this.item = item;
			this.sum = sum;
			this.typ = null;
			this.country = null;
			this.coordinates = null;
			this.Location = null;
			this.Language = null;
			this.Followers = -1;
		}
		
		public Items(String item, int sum, String typ, String country, String coordinates){
			this.item = item;
			this.sum = sum;
			this.typ = typ;
			this.country = country;
			this.coordinates = coordinates;
			this.Location = null;
			this.Language = null;
			this.Followers = -1;
		}
		
		public Items(String item, int sum, String Location, String Language, int Followers){
			this.item = item;
			this.sum = sum;
			this.typ = null;
			this.country = null;
			this.coordinates = null;
			this.Location = Location;
			this.Language = Language;
			this.Followers = Followers;
		}
		
		public String getItem(){
			return item;
		}
		public void setItem(String item){
			this.item = item;
		}
		public int getSum(){
			return sum;
		}
		public void setSum(int sum){
			this.sum = sum;
		}

		public String getTyp() {
			return typ;
		}

		public void setTyp(String typ) {
			this.typ = typ;
		}

		public String getCountry() {
			return country;
		}

		public void setCountry(String country) {
			this.country = country;
		}

		public String getCoordinates() {
			return coordinates;
		}

		public void setCoordinates(String coordinates) {
			this.coordinates = coordinates;
		}

		public String getLocation() {
			return Location;
		}

		public void setLocation(String location) {
			Location = location;
		}

		public String getLanguage() {
			return Language;
		}

		public void setLanguage(String language) {
			Language = language;
		}

		public int getFollowers() {
			return Followers;
		}

		public void setFollowers(int followers) {
			Followers = followers;
		}
	}
}
